<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
   .box{
  width: 1000px;
  height: 1000px;
  margin: 200px auto;
  /* display: flex; */
}
.fenshu{
  width: 100px;
  height: 50px;
  margin: auto;
  font-size: 16px;
}
.score{
  font-size: 16px;
}
.box1{
  width: 500px;
  height: 20px;
  background-color: skyblue;
  border-radius: 10px;
  margin: 10px auto;
  
}
.box2{
  width: 200px;
  height: 20px;
  background-color: skyblue;
  border-radius: 10px;
  position: relative;
  transition: all 0.6s;
}
.tuxing{
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: rgb(198, 165, 32);
  position: absolute;
  right: -4px;
  top: -2px;
}
  </style>
</head>
<body>
 <div class="box">
    <div class="fenshu">分数：<span class="score">40</span></div>
    <div class="box1">
      <div class="box2">
        <div class="tuxing"></div>
      </div>
    </div>
  </div>
  <script>
    const big = document.querySelector('.box1')
    const box2 = document.querySelector('.box2')
    const score = document.querySelector('.score')
    big.addEventListener('click', function(e){
      let lv = e.clientX - this.offsetLeft
      box2.style.width = lv +'px'
      // console.log(e.clientX)
      // console.log(this.offsetLeft)
      let fenshu = Math.round(lv / 5)
      score.innerHTML = fenshu
      
    })


  </script>
</body>
</html>